<template>
    <div class="container">
        <div class="flex flex-end">
            <el-button v-if="searchList.length" size="small" type="primary" @click="deleteHistory">清空历史</el-button>
        </div>
        <div v-if="searchList.length" class="list-content">
            <div class="list-item" v-for="(item,index) in searchList" :key="index" @click="toDetail(item.companyId)">
                <div class="company-name">{{item.companyName}}</div>
                <div class="item-info">
                    <span>法定代表人：{{item.legalPerson}}</span>
                    <span>注册资本：{{item.registeredCapital}}</span>
                    <span>成立日期：{{item.establishTime}}</span>
                </div>
                <div class="item-info">
                    <span>所属行业：{{item.industry}}</span>
                </div>
                <div class="item-info">
                    <span>地址：{{item.companyAddress}}</span>
                </div>
            </div>
        </div>
        <div v-else class="full-w flex-col flex-center items-middle no-data">
            暂无数据
        </div>
        <!-- 分页 -->
        <div class="pageList">
            <div class="page">
                <paging ref="paging_zi" @CurrentPage="accept_CurrentValue"/>
            </div>
        </div>
    </div>
</template>
<script>
import {searchHistoryList,deleteSearch} from '../../../api/api.js'
import paging from "@/components/paging.vue";
export default {
    components: {
        paging
    },
    data() {
        return {
            search:{
                pageNo: 1,
                pageSize: 10
            },
            searchList: []
        }
    },
    mounted() {
        this.getList()
    },
    methods: {
        // 搜索历史列表
        getList() {
            searchHistoryList(this.search).then(res=>{
                this.searchList = res.result.records
                this.$refs.paging_zi.totalValue(res.result.total)
            })
        },
        // 清空历史记录
        deleteHistory() {
            this.$confirm(`确认删除?`, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                deleteSearch().then(res=>{
                    this.getList()
                    this.$message({ type: 'success', message: '操作成功!' })
                })
            })
        },
        accept_CurrentValue(value) {
            this.search.pageNo = value;
            this.getList();
        },
        toDetail(id) {
            window.open("/enterprise/honor?id=" + id, "_blank");
        }
    }
}
</script>
<style lang="less" scoped>
.container{
    .list-content{
        .list-item{
            padding: 20px 0;
            border-bottom: 1px solid #eee;
            cursor: pointer;
            .company-name{
                font-size: 18px;
                font-weight: 600;
                margin-bottom: 5px;
            }
            .item-info{
                margin-bottom: 5px;
                span{
                    margin-right: 20px;
                    color: #999;
                }
            }
        }
    }
     /* 这里是分页 */
    .pageList {
        height: 100px;
        display: flex;
        flex-direction: row-reverse;
    }
    .page {
        display: flex;
        float: right;
        align-items: center;
        .pageNum {
            font-size: 14px;
            margin-right: 20px;

            span {
                color: #44a2ff;
                margin: 0 5px;
            }
        }
        .tempPage {
            margin-left: 10px;
            input {
                margin: 0 5px;
                text-align: center;
                width: 30px;
                height: 30px;
                border: 1px solid #ccc;
            }
        }
    }
}
</style>